<?php
require_once(dirname(__FILE__)."/../config/session.php");
require_once(dirname(__FILE__)."/../config/config.inc.php");
require_once(dirname(__FILE__)."/../libs/string/libstr.php");
require_once(dirname(__FILE__)."/../libs/login/login.php");
require_once(dirname(__FILE__)."/../libs/io/fileclass.php");
require_once(dirname(__FILE__)."/../libs/dbclass/dbconnect.php");
$mc=new libstr();
$lp=new login();
$fil=new fileclass();

//用户登录
function login1($userid,$password){
	global $mc;
	global $db;
	global $dbs;
	
if($userid=="" || $password==""){
 	return "0|userid or passoword is null";
 }
 
if($userid!="" && $password!="")
{
	
$mb=$db->ds("select * from member_content where userid='".trim($userid)."' and password ='".strtoupper(md5(trim($password)))."'");
	if(count($mb)>0)
	{
	 
      return "2|login is ok,userno=".trim($mb[0]["userno"]).",username=".trim($mb[0]["username"]).",rootid=".trim($mb[0]["rootid"]).",gyid=".trim($mb[0]["gyid"]);
	}
	
	else 
	{
 return "1|userid or password is wrong";
	}
}
}
//登录
function member_login1($userid,$password){
	global $mc;
	global $db;
	global $dbs;
	
if($userid=="" || $password==""){
 	return "0|userid or passoword is null";
 }
 
if($userid!="" && $password!="")
{
	
$mb=$db->ds("select id,userid,userno,username,password,pic,mc_code from member_content where userid='".trim($userid)."' and password ='".strtoupper(md5(trim($password)))."'");
	if(count($mb)>0)
	{
	 return $mb[0];
	}
	
	else 
	{
 return "1|userid or password is wrong";
	}
}
}
function update_code1($userno,$password,$mc_code){
    global $mc;
	global $db;
	global $dbs;
	
	if($userno=="" || $password==""){
 	return "userno or passoword is null";
 }
 
 	if($mc_code==""){
 	return "mc_code is null";
 }
 $mb=$db->ds("select id,userid,userno,username,password,pic,mc_code from member_content where userno=".trim($userno)." and password ='".strtoupper(md5(trim($password)))."'");
 
 if(count($mb)==0)
	{
return "userno or password is wrong";
	}
	
 $db->cmd("update member_content set mc_code='".trim($mc_code)."' where userno=".$mb[0]["userno"]);
 return "update is ok";

}



//用户注册
function reg1($userid,$password,$email){
	
	global $mc;
	global $db;
	global $dbs;
	global $lp;
  if($mc->Ismp($userid)=="" || $mc->Ismp($password)=="")
{ 
 
return "0|userid or password is null";
}
    if($mc->Ismp($email)=="" )
{ 
 
return "1|email is null";
}
		
		$myts=$dbs->dvstr("select count(*) as t from member_content where userid='".trim($userid)."'");
		$myts1=$dbs->ds("select * from member_content where userid='".trim($userid)."'");
		if($myts["t"]!="0")
		{
	 
			return "2|userid is exit,userno=".$myts1[0]["userno"];
			 
		}



	if($lp->reg(trim($userid),$userid,trim($password),trim($password),trim($email),false,"","","0","","","13800000000"))
	{
	
       return "3|reg is ok,userno=".$lp->tuserno;


	}else
	{

			return "4|reg no";
	
	}	
	
}

//获得主类别
function getclass1($cataid){
	global $dbs;
	global $db;
	global $mc;
	global $lp;


	$sql="select ID,classname,rootid,(select count(b.ID) as tt from product_class as b where b.pid=t.ID) as tj from product_class as t where t.pid in(99) or t.ID =102";
	$_rehit=(string)$cataid;//如果是数字类型的话0相当为null
	if($_rehit!="")
	{
		$sql="select ID,classname,rootid,(select count(b.ID) as tt from product_class as b where b.pid=t.ID) as tj from product_class as t where t.pid=".$_rehit;

	}
	$getrs=$db->ds($sql);
	return $getrs;
}
//获得年级类别
function getnianji_class1(){
	global $db;
$getrs=$db->ds("select ID,classname from nianji_class");
return $getrs;
}
//获得学段类别
function getxueke_class1($cataid){
	global $db;
$_rehit=(string)$cataid;//如果是数字类型的话0相当为null
$sql="select ID,classname,rootid,(select count(b.ID) as tt from xueke_class as b where b.pid=t.ID) as tj from xueke_class as t where t.pid=0";
	if($_rehit!="")
	{
		$sql="select ID,classname,rootid,(select count(b.ID) as tt from xueke_class as b where b.pid=t.ID) as tj from xueke_class as t where t.pid=".$_rehit;

	}
	$getrs=$db->ds($sql);
return $getrs;
}
//获得课件类别
function getbanben_class1(){
	global $db;
$getrs=$db->ds("select ID,classname from banben_class ");
return $getrs;
}
//获得学科类别
function getxueduan_class1(){
	global $db;
$getrs=$db->ds("select ID,classname from xueduan_class ");
return $getrs;
}
//获得年龄段
function getnianling_class1(){
	global $db;
$getrs=$db->ds("select ID,classname from nianling_class ");
return $getrs;
}


//获得商品列表
function  getgyid($str)
{
	global $dbs;

	$tx=$dbs->dvstr("select companyname,gyid from gongyingshang_content where gyid=".$str."");
	$tx=$tx["companyname"];
	return $tx;
}

function  getclassname($str)
{
	global $dbs;

	$tx=$dbs->ds("select classname,ID from product_class where rootid='".$str."'");
	$tx=$tx[0]["classname"];
	return $tx;
}

function  getclassid($str)
{
	global $dbs;

	$tx=$dbs->ds("select classname,ID from product_class where rootid='".$str."'");
	$tx=$tx[0]["ID"];
	return $tx;
}
function getshuxing($tabl,$ID)
{
	global $dbs;

	$tx=$dbs->ds("select classname,ID from ".$tabl." where ID='".$ID."'");
	$tx=$tx[0]["classname"];
	return $tx;
}

function getshuxing1($tb,$str)
{
	global $dbs;
	$sx=explode("|",$str);
	$sxstr="";
	for($i=0;$i<count($sx);$i++){
		$tx=$dbs->dvstr("select classname,ID from ".$tb." where rootid='".$sx[$i]."'");
		$sxstr.=$tx["classname"].",";
		
	}
	$sxstr=substr($sxstr,0,strlen($sxstr)-1);
	return $sxstr;
}

function getname1($ID){
    global $dbs;
	$tx=$dbs->ds("select classname,ID from product_class where ID=".$ID."");
	$tx=$tx[0]["classname"];
	return $tx;
}
function getcontent1($keyword,$item,$cataid,$price_free,$nianji,$xueke,$nandu,$banben,$nianling,$order,$sj,$pagesize,$page,$tuijian,$startage,$endage){
	global $dbs;
	global $db;
	global $mc;
	global $pg;

	$_keyword=str_replace("关键字","",$keyword);
	$_item=$item;
	$_where=" isshow>=9 ";
		$_item=$mc->requests($item,"CONCAT(topicname,jianjie,zhongdian,keyword)");
		if($_keyword !="")
	{
		$_where	.=" and ".$_item." like '%".trim(urldecode($_keyword))."%' ";
	}
	if($cataid!="")
	{
		if(!$mc->isnum($cataid))
		{
			echo "发送的ID必须是数字类型";
			exit();
		}
		$_cataid=$dbs->getrootdata("product_class",$cataid);
		$rootid =" and rootid like '%".$_cataid."%'";
	}
	   if($price_free!="")
   {
     $_where.=" and price_free=".$price_free;
   }
    if($nianji!="")
   {
     $_where.=" and nianji=".$nianji;
	 
   }
   if($xueke!="")
   {
    $_where.=" and xueke=".$xueke;
	 //$_xueke=$dbs->getrootdata("xueke_class",$xueke);
		//$_where.=" and xueke like '%".$_xueke."%'";
   }
     if($nandu!="")
   {
      $_nandu=$dbs->getrootdata("nandu_class",$xueke);
		$_where.=" and nandu like '%".$_nandu."%'";
   }

    if($banben!="")
   {
    // $_where.=" and banben=".$banben;
	 $_banben=$dbs->getrootdata("banben_class",$banben);
		$_where.=" and banben like '%".$_banben."%'";
   }
 
   if($nianling!="")
   {
     //$_where.=" and nianling=".$nianling;
	  $_nianling=$dbs->getrootdata("nianling_class",$nianling);
		$_where.=" and nianling like '%".$_nianling."%'";
   }
   
 //  if($startage!=""){
//
//		$_where.=" and startage >= ".$startage;
//	}
//	if($endage!=""){
//		if(!$mc->isnum($endage))
//		{
//			return  "发送的ID必须是数字类型";
//
//		}
//		$_where.=" and endage <= ".$endage;
//
//	}
   
 if($tuijian!="")
 {
    // $_where.=" and tuijian=".$tuijian;
	$_where.=" and tuijian=1";
 }
//return $_where;
 	$_order=$mc->requests($order,"updatetime");
	$_sj=$mc->requests($sj,"desc");
	if(ereg(",",$_order)==1)
	{
		$fggk=split(",",$_order);
		$_order=$fggk[0];
		$_sj=$fggk[1];

	}
$_pagesize=$mc->requests($pagesize,"desc");
$_tb="product_content";
	$_where ="".$_where.$rootid.$_tuijie;
	$order=" order by ".$_order." ".$_sj." ";
	$pagesize_xiaoquan=$_pagesize;	
	 $totalcount_xiaoquan=$db->getcount("id",$_tb,$_where);
	$page=$mc->requests($page,1);
		$getrs=$db->pagerds("id,topicname,codeid,price_m as price, pic,price_free,dhit,hit,xing as fenshu,gyid as ziyuanshang,jianjie,content,updatetime,rootid,nianling,startage,endage",$_tb,$_where,$order,$totalcount_xiaoquan,$pagesize_xiaoquan,$page);
	//$getrs="dfgd";
    $pppaggee= $totalcount_xiaoquan;
  //  return $order;
	$i=0;
	foreach ($getrs as $rs)
	{
	    $getrs[$i]["ziyuanshang"]=getgyid($rs["ziyuanshang"]);
		
		 $getrs[$i]["classname"]=getclassname($rs["rootid"]);
		 $getrs[$i]["cataid"]=getclassid($rs["rootid"]);
		  $nls=explode("|",$rs["nianling"]);
		 $getrs[$i]["nianlings"]=getshuxing1("nianling_class", $nls[0]);
		 
		  //$getrs[$i]["nianling"]=getshuxing("nianling_class",$rs["nianling"]);
		  $getrs[$i]["nianling"]=getshuxing1("nianling_class",$rs["nianling"]);
		  $getrs[$i]["nl"]=0;
		  if(ereg(",",$getrs[$i]["nianling"])==1){
		  $getrs[$i]["nl"]=1;
		  }
		  
		 // if($rs["nianling"]==0){
//		  $getrs[$i]["nianling"]="不确定";
//		  }
//		  
		  
		  //$getrs[$i]["nianlingduan"]=$getrs[$i]["startage"]."~".$getrs[$i]["endage"]."岁";
//		  if($getrs[$i]["startage"]=="" && $getrs[$i]["endage"]==""){
//		   $getrs[$i]["nianlingduan"]="不确定";
//		  
//		  }
		 
		$getrs[$i]["totalcount"]=$pppaggee;
		$getrs[$i]["pic"]=$mc->gethost().$mc->getthumbpic($mc->showpic($rs["pic"],0,"/uploadfile/nopic0.gif"));
		
	$i++;
	}
		
	return $getrs;
}

//获得产品详细
function getshow1($id,$ishit){
	global $dbs;
	global $db;
	global $mc;

if($id!=""){
	if(!$mc->isnum($id))
	{
		echo "0|ID is not num";
		exit();
	}
$getrs=$db->dvstr("select id,topicname,codeid,price_m as price, pic,pics,price_free,dhit,hit,xing as fenshu,gyid as ziyuanshang,jianjie,content,updatetime,rootid,nianling,zhongdian,daxiao,pingjia ,banben,xueke from product_content where isshow>=9 and id=".$id."");
if($ishit==0){
	$mysqlstr="update product_content set hit=hit+1 where id =".$id;
	$db->cmd($mysqlstr);
	}
} 

  $getrs["ziyuanshang"]=getgyid($getrs["ziyuanshang"]);
 $getrs["classname"]=getclassname($getrs["rootid"]);
 
    if($getrs["nianling"]==""){
		  $getrs["nianling"]="不确定";
		  }else{
		   $getrs["nianling"]=getshuxing1("nianling_class",$getrs["nianling"]);
		  }
		    if($getrs["banben"]==""){
		  $getrs["banben"]="不确定";
		  }else{
		   $getrs["banben"]=getshuxing1("banben_class",$getrs["banben"]);
		  }
		  if($getrs["xueke"]==0){
		  $getrs["xueke"]="不确定";
		  }else{
		   $getrs["xueke"]=getshuxing("xueke_class",$getrs["xueke"]);
		  }
  $getrs["cataid"]=getclassid($getrs["rootid"]);
  $getrs["pic"]=$mc->gethost().$mc->getthumbpic($mc->showpic( $getrs["pic"],0,"/uploadfile/nopic0.gif"));
 $getrs["pics"]=$mc->showpic( $getrs["pics"],-1,"");
 //$getrs["pics1"]=$mc->showpic( $getrs["pics"],-1,"");
  
   $getrs["picscount"]=count($getrs["pics"]);
	for($i=0;$i<count($getrs["pics"]);$i++)
	{
	$getrs["jpics"][$i]=$mc->gethost().$getrs["pics"][$i];
	}
	
	$getrs["path"]=$dbs->mappath("product_class",$mc->Ismp($getrs["cataid"]),"<a href='/'>首页</a>","list.php",true,true,0,">","#0087ff");

return $getrs;

}
//提交评论
function postcomment1($userno,$password,$id,$content,$fenshu,$pingjia){
	global $dbs;
	global $db;
	global $mc;
	
	if($mc->Ismp($userno)=="" || $mc->Ismp($password)=="")
{ 
return  "0|userno or password is null";

}
$mb=$db->ds("select * from member_content where userno='".trim($userno)."'");
	if($mb[0]["password"]!=strtoupper(md5($mc->Ismp($password))))
	{
	return  "1|userno or password is wrong";
	
}
	if($mc->requests($id,"")==""){
			return  "2|id is null";
		
	}       
		if($mc->requests($content,"")==""){
			return  "3|content is null";
			
}
	
//$_shopno=$mc->request("shopno","0");
$_shopno=0;
//$_topicname=$mc->request("topicname","");
$_topicname="";
$_userid=$mb[0]["userid"];
//$_headpic=$mc->request("headpic","");
$_headpic="";
$_username=$mb[0]["username"];
$_content=$mc->requests($content,"");
$_hit=$mc->request("hit","0");
$_hit=1;
$_userno=$mb[0]["userno"];
$_fid=0;
$_goodsno=$mc->requests($id,"0");
$_fenshu=$mc->requests($fenshu,"5");
$_pingjia=$mc->request($pingjia,"1");
$_rootid="";
$_createtime=date("Y-m-d H:i:s");
$_ip=$mc->getip();
$_isshow=1;
$_getid="";
$_mypic=$mb[0]["pic"];

$sql="insert into comment_content(shopno,topicname,userid,headpic,username,content,hit,userno,fid,goodsno,fenshu,pingjia,rootid,createtime,ip,isshow,getid,mypic)values
		(".$_shopno.",'".$_topicname."','".$_userid."','".$_headpic."','".$_username."','".$_content."',".$_hit.",'".$_userno."',".$_fid.",".$_goodsno.",".$_fenshu.",".$_pingjia.",'".$_rootid."','".$_createtime."','".$_ip."',".$_isshow.",' ', '".$_mypic."')";
		
$dbs->cmd($sql);
return "4|post is ok";
}
//获得评论
function getcomment1($userno,$pingjia,$id,$pagesize,$order,$sj,$page){
	global $dbs;
	global $db;
	global $mc;
	
	 $_where=" isshow>=0 ";

 if($mc->request($userno,"")!="")
   {
     $_where.=" and userno=".$mc->requests($userno,"");
   }
   
      if($mc->requests($pingjia,"")!="")
   {
     $_where.=" and pingjia=".$mc->requests($pingjia,"");
   }
   
   if($mc->requests($id,"")!="")
   {
     $_where.=" and goodsno=".$mc->requests($id,"");
   }
    $_pagesize=$mc->requests($pagesize,"10");
	$_tb="comment_content";
	$_order=$mc->requests($order,"createtime");
	$_sj=$mc->requests($sj,"desc");
	
	$order=" order by ".$_order." ".$_sj." ";

	$pagesize_xiaoquan=$_pagesize;
	$totalcount_xiaoquan=$db->getcount("id",$_tb,$_where);
	$page=$mc->requests($page,1);
	$getrs=$db->pagerds("id,content,fenshu,pingjia,userno,userid,username,mypic,goodsno,createtime",$_tb,$_where,$order,$totalcount_xiaoquan,$pagesize_xiaoquan,$page);

	$pppaggee= $totalcount_xiaoquan;
	$i=0;
	foreach ($getrs as $rs)
	{
	  
		$getrs[$i]["totalcount"]=$pppaggee;
				
		//echo $getrs[$i]["totalcount"];
    $i++;
	}
	return $getrs;
}
//获得下载地址
function getfile1($codeid,$userno,$password){
	
	global $dbs;
	global $db;
	global $mc;
	global $fil;
	
	
	if($mc->Ismp($codeid)!="")
{
    $kop2=$db->dvstr("select topicname,id,price_free,codeid,durl from product_content where codeid=".$codeid."");
	 //if($kop2["price_free"]==0)
	// {
	 if($mc->Ismp($userno)=="" || $mc->Ismp($password)=="")
{ 
return  "0|userno or password is null";

}

$mb=$db->ds("select * from member_content where userno='".trim($userno)."'");
	if($mb[0]["password"]!=strtoupper(md5($mc->Ismp($password))))
	{
	return "1|userno or password is wrong";
	
	}
	  // $kj=$db->ds("select * from cart_content where zhuangtai >=2 and  userno =".$userno." and codeid =".$codeid);
	  //if(count($kj)==0){
	   
// return "2|no pay";
	 
	//  }
// }
 
	$fname1=$kop2["durl"];
	
	$fname1=str_replace("'","",$fname1);
	
		if($mc->Ismp($fname1)=="")
	{
		return "4|file is wrong";
	
		
	}
	
    $thefilepath1=$fil->getrootdirpath().$fname1;
    if($fil->file_exit($thefilepath1))
	{
		
		$mysqlstr="update product_content set dhit=dhit+1 where codeid =".$codeid;
		$db->cmd($mysqlstr);
		return $fname1;
	}
	if(!$fil->file_exit($thefilepath1))
	{
		return "4|file is wrong";
	    //echo $thefilepath1;
		
	}
     if($fil->file_copy($thefilepath1,iconv("UTF-8","gb2312", $thefilepath3))){
	 // return  "3|fileurl=".$mc->gethost().$fname1;
	 return $fname1;
	 
		}
}else
{
return  "5|codeid is null";
}
}

//支付函数
function cardpay1($userid,$userid2,$cardno,$cardpassword){
	global $dbs;
	global $db;
	global $mc;
	if($userid=="")
	{
	
		return "0|userid is null";
	}
	if($userid!=$userid2)
	{
		
		return "1|userid not equal userid2";
	}
	if($cardno=="")
	{
		
		return "2|cardno is null";
	}
	if($cardpassword=="")
	{
		 
		return  "3|cardpassword is null";
	}
	$getdrs=$db->ds("select userno,gyid from member_content where userid ='".trim($userid)."'");
	if(count($getdrs)==0)
	{
		 
		return "4|userid is exit";
	}
	if($getdrs[0]["gyid"]!="0")
	{
		 
		return "5|the userid is not sortpport";
	}
	$cardrs=$db->ds("select * from card_content where password='".trim($cardpassword)."' and cardno ='".trim($cardno)."'");
	//echo "select * from card_content where password='".trim($_POST["password"])."' and cardno ='".trim($_POST["cardno"])."'";
	if(count($cardrs)==0)
	{
		 
		return "6|the cardno or the cardpassword wrong";
	}

	if($cardrs[0]["isused"]!=0)
	{
		 
		return "7|the cardno be userd";
	}
	$db->cmd("update member_content set tjinqian=tjinqian+".$cardrs[0]["x_price"]." where userno=".$getdrs[0]["userno"]."");
	$db->cmd("update card_content set isused=1,jitime='".date("YmdHis")."',userno='".$getdrs[0]["userno"]."' where isused=0 and cardno=".$cardrs[0]["cardno"]."");

    $dingid=$cardrs[0]["cardno"];
	$_x_text="卡类充值：".$cardrs[0]["cardno"];
	$_x_price=$cardrs[0]["x_price"];
	$_userno=$getdrs[0]["userno"];
	$_x_stat="ok";
	$_zt=1;
	$_lx=0;
	$sql="insert into jiaoyi_content(x_text,x_price,x_stat,zt,createtime,lx,dingdanhao,userno)values('".$_x_text."',".$_x_price.",'".$_x_stat."','".$_zt."','".date("Y-m-d H:i:s")."',".$_lx.",".$dingid.",".$_userno.")";
	//echo $sql;
	//exit();
	$db->cmd($sql);
	 return "8|pay is ok";
	
}
//保存订单
function saveorder1($userno,$password,$codeid){
	global $dbs;
	global $db;
	global $mc;
	global $lp;
		$myuserno=$mc->requests($userno,"");
	$mycodeid=$mc->requests($codeid,0);
	if($myuserno==""){
		return "0|userno is null";
	}
		if($mycodeid==""){
		return "1|codeid is null";
	}
	
	$pdrs=$db->ds("select * from product_content where codeid=".$codeid);
	 
	if(count($pdrs)==0)
	{
		return "2|product is null";
	}

	$grs=$db->dvstr("select * from member_content where userno=".$myuserno."");
    if($grs["password"]!=strtoupper(md5($mc->requests($password,"")))){
    	return "3|password is wrong";
    }

		if($pdrs[0]["price_m"]>$grs["tjinqian"])
		{
         return "4|money less";
		}
	
	if($pdrs[0]["price_free"]>0){
		return "5|the product is free";
	}
	$dtime=date("Y-m-d H:i:s");
	srand((double)microtime()*1000000);
	$randval = substr(rand(), 0,4);
	$myordeidid=date("YmdHis").$randval;
	
	//	print_r($_POST);
	//exit();
	//------------------
	$_userno=$myuserno;
	$_username=$grs["username"];
	$_userid=$grs["userid"];
	$_sex=0;

  
	$_dingdanhao=$myordeidid;
	$_creattime=$dtime;
	$_email=$grs["email"];
	$_qq="";
	$_shouji=$grs["shouji"];
	$_tel=$grs["dianhua"];
	$_dizhi=$grs["dizhi"];
	$_youbian="";
	$_content="来自客户端";
	$_peisong="songhuo";
	$_peisongprice=0;
	$_zhifufangshi=huokuan;
	$_zhifuprice=0;
	$_fapiao="";
	$_fapiaoprice=0;
	$_fapiaotaitou="";
	$_jifen=0;
	$_jifenstat=0;
	$_zhuangtai="0";
	$_zhongliang=0;
	$_chengshi="";
	$_zongjia=$pdrs[0]["price_m"];
	$_isshow=0;
	$_updatetime=date("Y-m-d H:i:s");
	$_paytime=$_updatetime;

    $xk="2";
    $xb="1";
	if($_zhifufangshi=="huokuan")
	{
	$xk="6";
    $xb="5";
    if($lp->getsession("rootid")=='0,5,')
	{
	  $xk="2";
      $xb="1";
	}
	
    $dingid=$_dingdanhao;
	$_x_text="消费";
	$_x_price=$_zongjia;
	$_userno=$myuserno;
	$_x_stat="ok";
	$_zt=1;
	$_lx=1;
	$sql="insert into jiaoyi_content(x_text,x_price,x_stat,zt,createtime,lx,dingdanhao,userno)values('".$_x_text."',".$_x_price.",'".$_x_stat."','".$_zt."','".date("Y-m-d H:i:s")."',".$_lx.",".$dingid.",".$_userno.")";
	
	//echo $sql;
	//exit();
	$db->cmd($sql);
	$db->cmd("update member_content set tjinqian=tjinqian-".$_x_price.",xjinqian=xjinqian+".$_x_price." where userno=".$myuserno."");
    
	}
	$_rootid=$dbs->getrootdata("order_class",$xk);
	$_rootid1=$dbs->getrootdata("zhifu_class",$xb);
	$_chuhuotime=$_creattime;
	$_ems=$mc->request("ems","");
	$_beizhu="";
	$_gyid="0";
	$ordersql="insert into order_content(gyid,userno,username,userid,sex,dingdanhao,creattime,email,qq,shouji,tel,dizhi,youbian,content,peisong,peisongprice,zhifufangshi,zhifuprice,fapiao,fapiaoprice,fapiaotaitou,jifen,jifenstat,zhuangtai,zhongliang,chengshi,zongjia,rootid,isshow,updatetime,paytime,rootid1,chuhuotime,ems,beizhu)values(".$_gyid.",".$_userno.",'".$_username."','".$_userid."',".$_sex.",'".$_dingdanhao."','".$_creattime."','".$_email."','".$_qq."','".$_shouji."','".$_tel."','".$_dizhi."','".$_youbian."','".$_content."','".$_peisong."',".$_peisongprice.",'".$_zhifufangshi."',".$_zhifuprice.",'".$_fapiao."',".$_fapiaoprice.",'".$_fapiaotaitou."',".$_jifen.",".$_jifenstat.",".$_zhuangtai.",".$_zhongliang.",'".$_chengshi."',".$_zongjia.",'".$_rootid."',".$_isshow.",'".$_updatetime."','".$_paytime."','".$_rootid1."','".$_chuhuotime."','".$_ems."','".$_beizhu."')";
	//echo $ordersql;
	//exit();
	$db->cmd($ordersql);

	//------------------
	foreach ($pdrs as $rs)
	{
		$_topicname=trim($rs["topicname"]);
		$_codeid=trim($rs["codeid"]);
		$_url="";
		$_dingdanhao=trim($myordeidid);
		$_creattime=trim($dtime);
		$_price_m=trim($rs["price_m"]);
		$_price_s=trim($rs["price_s"]);
		$_price_v=trim($rs["price_m"]);
		$_num=1;
		$_zhongliang=0;
		$_jifen=0;

		$_price_y=trim($rs["price_m"]);
		$_updatetime=$dtime;
		$_zhuangtai="1";
		if($_zhifufangshi=="huokuan")
	    {
			$_zhuangtai="2";
		}
			
	if($lp->getsession("rootid")=='0,5,')
	{
	 	$_zhuangtai="3";
	}
		$_gyid=trim($rs["gyid"]);
		$_xishu="0";
		$getxishu=$db->dvstr("select xishu from gongyingshang_content where gyid=".$_gyid."");
		if($getxishu["xishu"]!="")
		{
			$_xishu=$getxishu["xishu"];
		}
		$db->cmd("insert into cart_content(xishu,gyid,userno,topicname,codeid,url,dingdanhao,creattime,price_m,price_s,price_v,num,zhongliang,jifen,userid,price_y,updatetime,zhuangtai,a1,a2)values(".$_xishu.",".$_gyid.",".$_userno.",'".$_topicname."','".$_codeid."','".$_url."','".$_dingdanhao."','".$_creattime."',".$_price_m.",".$_price_s.",".$_price_v.",".$_num.",".$_zhongliang.",".$_jifen.",'".$_userid."',".$_price_y.",'".$_updatetime."',".$_zhuangtai.",'".trim($rs["a1"])."','".trim($rs["a2"])."')");

	}
	return "6|order is ok,orderno=".$myordeidid;
	
}

?>